package com.sbl.bajw.common.web;

import java.util.List;

import org.apache.poi.ss.formula.functions.T;

import com.sbl.bajw.util.JsonUtil;

public class JsonResultUtil {

	public static String Error(String msg){
		String result = Success(msg,"");
		return result;
	}
	
	public static String Success(String data){
		String result = Success("成功",data);
		return result;
	}
	
	public static String Success(){
		String result = Success("成功","\"成功\"");
		return result;
	}
	
	public static String Success(String msg, List<T> list){
		String str = JsonUtil.ConvertArrayToJson(list);
		String result = Success(msg, str);
		return result;
	}
	
	public static String Success(String msg, String data){
		String json = "{\"code\":\"1\",";
		if(msg != null && !"".equals(msg)){
			json += "\"msg\":\"" + msg + "\",";
		}else{
			json += "\"msg\":\"成功\",";
		}
		json += "\"success\":\"true\",";
		if(data != null && !"".equals(data)){
			json += "\"data\":" + data + "}";
		}else{
			json += "\"data\":\"null\"}";
		}
		return json;
	}
}
